﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using bank.DTOs;

public partial class validation_Registration : System.Web.UI.Page
{
    private string stud;
    protected void Page_Load(object sender, EventArgs e)
    {
        //var s2 = string.Format("Hi {0} kemon acho, your age is {1}", txtName.Text, txtAge.Text);
        //var s = string.Format("javascript:return chkReportName('{0}');", txtName.ClientID);
        txtName.Attributes.Add("onblur", string.Format("javascript:return chkName('{0}');", txtName.ClientID));
        btnShow.Attributes.Add("onclick", "javascript:alert('this is from code behind')");
        btnUpdate.Attributes.Add("onclick", "javascript:return confirm('Are you sure?')");
        btnAdd.Attributes.Add("onclick", string.Format("javascript:return chkName('{0}');", txtName.ClientID));
        txtAge.Attributes.Add("onkeypress", string.Format("javascript:return chkAge('{0}');", txtAge.ClientID));
        if (!Page.IsPostBack)
        {
            stud = System.IO.File.ReadAllText("c:\\tmp\\student.txt");
            Session["stud"] = stud; ;
            lblText.Text = stud;
        }
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        StudentInfo student = new StudentInfo();
        student.Age = Convert.ToInt32(txtAge.Text);
        student.Name = txtName.Text;

        stud = Session["stud"].ToString();
        stud = stud + student.Age + "  " + student.Name + "|";
        Session["stud"] = stud;
        lblText.Text = stud;


        //var stud = new StudentInfo { Age = Convert.ToInt32(txtAge.Text), Name = txtName.Text }; //object initializar

    }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        string stud = Session["stud"].ToString();
        System.IO.File.AppendAllText("c:\\tmp\\student.txt", stud);
    }

    protected void btnShow_Click(object sender, EventArgs e)
    {

    }
}